﻿using System.Diagnostics;
using System.IO;
using NExplorer.AddIns.WinRar.Properties;

namespace NExplorer.AddIns.WinRar
{
	internal class ExtractHereCommand : CommandBase
	{
		public ExtractHereCommand()
			: base("Extract Here")
		{}

		protected override void Execute(FileSystemInfo fileSystemInfo)
		{
			FileInfo fileInfo = fileSystemInfo as FileInfo;

			if (fileInfo != null && WinRarUtility.ConfirmWinRarAvailable())
			{
				ProcessStartInfo startInfo = new ProcessStartInfo(Settings.Default.WinRarFullPath);
				startInfo.Arguments = string.Format("X \"{0}\" \"{1}\"", fileInfo.FullName, fileInfo.Directory.FullName);

				Process.Start(startInfo);
			}
		}
	}
}
